package com.ljm.common.util;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.net.InetAddress;
import java.net.UnknownHostException;

public class IPUtils {
    private IPUtils(){}
    static final Logger logger = LoggerFactory.getLogger(IPUtils.class);

    public static String getLocalIpAddress() {
        try {
            InetAddress address = InetAddress.getLocalHost();
            return address.getHostAddress();
        } catch (UnknownHostException e) {
            logger.error("get ip error", (Throwable) e);
            return "localhost";
        }
    }
}
